package com.giscloud.limp.controller;

import java.util.Arrays;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;

import com.giscloud.limp.entity.CaseRetrial;
import com.giscloud.limp.service.CaseRetrialService;
import com.giscloud.limp.entity.dto.CaseRetrialDTO;
import com.giscloud.datasource.page.PageInfo;
import java.math.BigDecimal;
import com.giscloud.commons.model.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;


/**
 * 再审案件信息
 *
 * @author giscloud
 * @email giscloud@giscloud.com
 * @date 2020-06-10 14:25:28
 */
@RestController
@RequestMapping("/limp/caseretrial")
@Log4j2
public class CaseRetrialController {

    private final CaseRetrialService caseRetrialService;

    @Autowired
    public CaseRetrialController(CaseRetrialService caseRetrialService) {
        this.caseRetrialService = caseRetrialService;
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody CaseRetrial caseRetrial){
        if(caseRetrial.getCaseId() == null){
            return Result.error(-1,"caseId 必填");
        }
        return caseRetrialService.save(caseRetrial);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody CaseRetrial caseRetrial){
        return caseRetrialService.updateById(caseRetrial);
    }

    /**
     * 删除(直接传数组对象即可，如：[1],[1,2]支持批量删除)
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Integer[] caseRetrialIds){
        return caseRetrialService.removeByIds(Arrays.asList(caseRetrialIds));
    }

}
